#!/usr/bin/env python3
# coding:utf-8

from flask import Flask, redirect, url_for
app = Flask(__name__)


@app.route("/admin")
def hello_admin():
    return "hello admin"


@app.route("/guest/<guest>")
def hello_guest(guest):
    return f"hello guest {guest}"


@app.route("/user/<name>")
def hello_user(name):
    if name == "admin":
        return redirect(url_for('hello_admin'))
    else:
        return redirect(url_for('hello_guest', guest=name))


any_ip = "0.0.0.0"
http_port = 8080
if __name__ == "__main__":
    app.run(any_ip, http_port)

"""
http://127.0.0.1:8080/user/admin --重定向--> http://127.0.0.1:8080/admin

http://127.0.0.1:8080/user/123 --重定向--> http://127.0.0.1:8080/guest/123
"""